import { createStore } from 'vuex'

export default createStore({
  state: {
    userInfo: {
      user_avatar: "https://c-ssl.duitang.com/uploads/item/201902/17/20190217004623_htvoq.jpg",
      nickname: "未登录",
      user_phone: "",
      vip_expired_time: "0001-01-01T00:00:00Z",
      is_vip: false,
      isLogin: false
    },
    windowInfo: {
      window_width: 0,
      window_height: 0,
      window_innerWidth: 0,
      window_innerHeight: 0
    },
    currentPage: "index",
    currentBuilding: {
      id: "",
      name: "",
      data3d: ""
    }
  },
  mutations: {
    SET_USER_INFO(state, userInfo) {
      state.userInfo = userInfo
    },
    SET_WINDOW_INFO(state, windowInfo) {
      state.windowInfo = windowInfo
    },
    SET_CURRENT_PAGE(state, currentPage) {
      state.currentPage = currentPage
    },
    SET_CURRENT_BUILDING(state, currentBuilding) {
      state.currentBuilding = currentBuilding
    },
    SET_IS_MOBILE(state, is_mobile) {
      state.is_mobile = is_mobile
    }
  },
  actions: {
    setUserInfo({ commit }, userInfo) {
      commit('SET_USER_INFO', userInfo)
    },
    setWindowInfo({ commit }, windowInfo) {
      commit('SET_WINDOW_INFO', windowInfo)
    },
    setCurrentPage({ commit }, currentPage) {
      commit('SET_CURRENT_PAGE', currentPage)
    },
    setCurrentBuilding({ commit }, currentBuilding) {
      commit('SET_CURRENT_BUILDING', currentBuilding)
    }
  },
  getters: {
    getUserInfo: state => state.userInfo,
    getWindowInfo: state => state.windowInfo,
    getCurrentPage: state => state.currentPage,
    getCurrentBuilding: state => state.currentBuilding
  }
})
